<template>
  <div>
    <edu-title title="作业记录" style="margin-bottom: 0"></edu-title>
    <div>
      <recordItem v-for="(item, index) in records" :item="item" :key="index">
        {{ item }}
      </recordItem>
    </div>
    <el-pagination
      class="pagination"
      @current-change="getHomeWorkListForCourse"
      :page-size="pageSize"
      hide-on-single-page
      layout="prev, pager, next, jumper"
      :total="total"
    >
    </el-pagination>
    <el-empty v-if="records.length <= 0"></el-empty>
  </div>
</template>

<script lang="ts">

import eduTitle from "/@/components/userCenter/title.vue";
import recordItem from "/@/components/userCenter/homeworkRecordItem.vue";
import { homeWorkListForCourse } from "/@/api/studyApi";

export default {
  components: {
    eduTitle,
    recordItem,
  },
  data() {
    return {
        total:0,
        pageSize:20,
      records: [],
    };
  },
  mounted(){
      this.getHomeWorkListForCourse()
  },
  methods: {
    getHomeWorkListForCourse(page = 1, params = {}) {
      let offset = (page - 1) * this.pageSize;
      homeWorkListForCourse({
        offset: offset,
        size: this.pageSize,
        courseId:this.$route.query.courseId,
        ...params,
      })
        .then((res) => {
          const { studyProgressLogs, total } = res;
          this.records = studyProgressLogs;
     
          this.total = total;
        })
        .catch((err) => {
          console.error(err);
        });
    },
  },
};
</script>

<style lang="scss" scoped>
</style>